package cc.yugu.yhdw.webserver.service.hdw;

import cc.yugu.yhdw.common.domain.hdw.ExchangePriceTime;
import cc.yugu.yhdw.common.entity.json.ExtResult;
import cc.yugu.yhdw.common.entity.pagination.Page;
import cc.yugu.yhdw.webserver.persistence.hdw.ExchangePriceTimeMapper;
import cc.yugu.yhdw.webserver.service.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 换电次数价格业务
 * 
 * @Date:Created in 2018/7/9 14:08
 * @Author:
 * @Modified By: zjn 2018/7/9 14:08
 */ 
@Service
public class ExchangePriceTimeService extends AbstractService {

    @Autowired
    ExchangePriceTimeMapper exchangePriceTimeMapper;
    /**
    * 分页查询
    * 
    * @Param: [search]
    * @Return: cc.yugu.yhdw.common.entity.pagination.Page
    * @Author By: zjn 2018/7/9  14:08
    */ 
    public Page findPage(ExchangePriceTime search) {
        Page page = search.buildPage();
        page.setTotalItems(exchangePriceTimeMapper.findPageCount(search));
        search.setBeginIndex(page.getOffset());
        page.setResult(exchangePriceTimeMapper.findPageResult(search));
        return page;
    }

    public ExchangePriceTime find(Long id) {
        return exchangePriceTimeMapper.find(id);
    }
    /**
    * 插入
    * 
    * @Param: [exchangePriceTime]
    * @Return: cc.yugu.yhdw.common.entity.json.ExtResult
    * @Author By: zjn 2018/7/9  14:09
    */ 
    public ExtResult insert(ExchangePriceTime exchangePriceTime) {
        if (exchangePriceTimeMapper.insert(exchangePriceTime) == 0) {
            return ExtResult.failResult("操作失败");
        }
        return ExtResult.successResult();
    }
    /**
    * 更新
    * 
    * @Param: [entity]
    * @Return: cc.yugu.yhdw.common.entity.json.ExtResult
    * @Author By: zjn 2018/7/9  14:09
    */ 
    public ExtResult update(ExchangePriceTime entity) {
        if (exchangePriceTimeMapper.update(entity) == 0) {
            return ExtResult.failResult("操作失败");
        }
        return ExtResult.successResult();
    }
    /**
    * 删除
    * 
    * @Param: [id]
    * @Return: cc.yugu.yhdw.common.entity.json.ExtResult
    * @Author By: zjn 2018/7/9  14:09
    */ 
    public ExtResult delete(Long id) {
        int total = exchangePriceTimeMapper.delete(id);
        if (total == 0) {
            return ExtResult.failResult("操作失败！");
        }
        return ExtResult.successResult();
    }
}
